﻿using Assets.Script.HelpSystem.AtkSystem.Base;
using Assets.Script.Human.Player;
using Assets.Script.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Assets.Script.HelpSystem.AtkSystem.AtkWays
{
    public class AtkWayGunSpecial : AtkWay
    {
        AudioClip atkActionClip;
        AudioSource audioSource;
        public AtkWayGunSpecial(PlayerBody playerBody, AtkInfo atkInfo, Dictionary<Type, int> bulletEffectLevel,int index) : base(playerBody, atkInfo, bulletEffectLevel,index)
        {
            attackDirAngleRange = 360f;
            attackDir = new AttackDir(36,0,0,0);
            atkActionClip = Resources.Load<AudioClip>(ResourcePath.Audio.GunShoot);
            audioSource = playerBody.gameObject.AddComponent<AudioSource>();
            audioSource.playOnAwake = false;
            audioSource.clip = atkActionClip;
        }

        protected override void SetData(params object[] o)
        {
            base.SetData(o);
            atkWaitTime = 1f / 2f;
        }

        protected override void AttackStart_m()
        {
            animator.SetFloat("atkSpeed", 1);
        }

        protected override void AttackEnd_m()
        {
            base.AttackEnd_m();
        }

        protected override void UpdateInAttack()
        {
            Attack_Invoke();
        }

        protected override void Attack_Normal()
        {
            base.Attack_Normal();
            audioSource.Play();
        }

    }
}
